<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>arguments获取设置非行间样式</title>
		<style>
			#div1{
				width:200px;
			    height: 200px;
			    background: red;
			}
			
			
		</style>
	</head>
	<body>
		<div id="div1"></div>
		<script>
			//页面加载时执行
			window.onload=function(){
				//获取div元素
				var div1=document.getElementById("div1");
				//调用getstyle()
				alert(getstyle(div1,"width"));
				getsyle(div1,"backgroud","blue");
			}
			function getstyle(obj,name,valaue){
				if(arguments.length==2){
					//
					if (obj.currentStyle) {
						return obj.currentStyle()[name];
					}else{
						return getComputedStyle(obj,false)[name];
					}
				}else if(arguments.length==3){
					obj.style[name]=value;
				}else{
					alert("函数调用参数有误！")
				}
			}
		</script>
	</body>
</html>
